<?php 
 define('PRODUCTS',23);
 define('COLS', 3);
 $rows = ceil( PRODUCTS / COLS )  ;
 echo "<table width='50%' align='center'>";
 for($i=1 ; $i<=$rows ; $i++) {
   $color = ($i%2==0)?'red':'green';
   echo "<tr>";
   echo "<td style='background:$color'>$i</td>";	
   echo "</tr>";
 }
 echo "</table>";
 